#include "mainwindow.h"
#include "ui_mainwindow.h"

#include "model.h"
#include<QPainter>

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    //  设置窗口大小
    setFixedSize(
        MARGIN * 2 + BLOCK_SIZE * BOARD_GRAD_SIZE,
        MARGIN * 2 + BLOCK_SIZE * BOARD_GRAD_SIZE);
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::paintEvent(QPaintEvent *event){
    QPainter painter(this);
    //绘制棋盘
    painter.setRenderHint(QPainter::Antialiasing,true);

    for(int i=0;i < BOARD_GRAD_SIZE + 1;i++)
    {
        //从左到右，第（i+1）条竖线
        painter.drawLine(MARGIN + BLOCK_SIZE * i,MARGIN,MARGIN + BLOCK_SIZE * i,size().height() - MARGIN);
        //从上到下，第（i+1）条横线
        painter.drawLine(MARGIN,MARGIN + BLOCK_SIZE * i,size().height() - MARGIN,MARGIN + BLOCK_SIZE * i);
    }
}
